package othello;

import othello.logic.GameGrid;
import othello.logic.MoveQueue;
import othello.gui.SetupGameDialog;
import othello.gui.DrawDialog;
import othello.gui.GameFrame;
import othello.gui.WinnerDialog;
import othello.logic.player.Player;

/**
 * Class GUIC - Graphical User Interface Controller.
 * Handles communication between logic and graphic.
 */
public class GUIC {
    GameFrame gameFrame;
    Player p1, p2;
    Othello main;
    
    public GUIC(Othello main){
        this.main = main;
        gameFrame = new GameFrame(new GameGrid(), this, main);
    }
    
    public void showSetupGameDialog(){
        SetupGameDialog sgd = new SetupGameDialog(gameFrame);
        p1 = sgd.getPlayer1();
        p2 = sgd.getPlayer2();
    }
    
    public Player getPlayer1(){
        return p1;
    }
    
    public Player getPlayer2(){
        return p2;
    }
    
    public void showWinnerDialog(String playerName){
        new WinnerDialog(gameFrame, playerName);
    }
    
    public void showDrawDialog(){
        new DrawDialog(gameFrame);
    }
    
    public void setNewGrid(GameGrid gameGrid){
        gameFrame.setNewGrid(gameGrid);
    }
    
    public void setNewMoveQueue(MoveQueue mq){
        gameFrame.setNewMoveQueue(mq);
    }

    public void repaintBoard() {
        gameFrame.repaint();
    }

    void dispose() {
        gameFrame.dispose();
        gameFrame = new GameFrame(new GameGrid(), this, main);
    }
}